package cn.ztuo.bitrade.controller.accessRecord;

import cn.ztuo.bitrade.annotation.AccessLog;
import cn.ztuo.bitrade.constant.AdminModule;
import cn.ztuo.bitrade.constant.SysConstant;
import cn.ztuo.bitrade.controller.BaseController;
import cn.ztuo.bitrade.entity.Admin;
import cn.ztuo.bitrade.service.AccessRecordService;
import cn.ztuo.bitrade.service.BorrowMoneyService;
import cn.ztuo.bitrade.service.LoanMoneyService;
import cn.ztuo.bitrade.util.MessageResult;
import cn.ztuo.bitrade.vo.AccessRecordVO;
import cn.ztuo.bitrade.vo.BorrowMoneyVO;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.SessionAttribute;

/**
 * @author: Xiazt
 * @date: 2020-05-19 17:00
 */
@RestController
@RequestMapping("accessRecord")
public class AccessRecordController extends BaseController {

    @Autowired
    private BorrowMoneyService borrowMoneyService;

    @Autowired
    private LoanMoneyService loanMoneyService;

    @Autowired
    private AccessRecordService accessRecordService;

    @RequiresPermissions("borrowMoney:page-query")
    @RequestMapping(value = "borrowMoney-page-query")
    @AccessLog(module = AdminModule.BORROWMONEY, operation = "分页获取币借贷借入列表数据")
    public MessageResult getBorrowMoneyList(@SessionAttribute(SysConstant.SESSION_ADMIN) Admin admin, BorrowMoneyVO borrowMoneyVO){
        return success(borrowMoneyService.getBorrowMoneyList(borrowMoneyVO));
    }

    @RequiresPermissions("loanMoney:page-query")
    @RequestMapping(value = "loanMoney-page-query")
    @AccessLog(module = AdminModule.LOANMONEY, operation = "分页获取币借贷借出列表数据")
    public MessageResult getLoanMoneyList(@SessionAttribute(SysConstant.SESSION_ADMIN) Admin admin, BorrowMoneyVO borrowMoneyVO){
        return success(loanMoneyService.getLoanMoneyList(borrowMoneyVO));
    }

    @RequiresPermissions("accessRecord:page-query")
    @RequestMapping(value = "accessRecord-page-query")
    @AccessLog(module = AdminModule.LOANMONEY, operation = "分页获取币借贷信息")
    public MessageResult getAccessRecordList(@SessionAttribute(SysConstant.SESSION_ADMIN) Admin admin, AccessRecordVO accessRecordVO){
        return success(accessRecordService.getAccessRecord(accessRecordVO));
    }

}
